using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BlazorOrdering.Web.Entry.Areas.Identity.Data;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;

namespace BlazorOrdering.Web.Entry.Pages
{
    public class LogoutModel : PageModel
    {
        private readonly SignInManager<BlazorOrderingUser> _signInManager;
        private readonly ILogger<LogoutModel> _logger;

        public LogoutModel(SignInManager<BlazorOrderingUser> signInManager, ILogger<LogoutModel> logger)
        {
            _signInManager = signInManager;
            _logger = logger;
        }
        public RedirectResult OnGet()
        {
            if (_signInManager.IsSignedIn(User))
            {
                 _signInManager.SignOutAsync();
            }

            return Redirect("~/");

        }
    }
}
